﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Ongoal.Quotation;
using Ongoal.Quotation.Service.Interface;
using Ongoal.Quotation.Service.Model;
using Ongoal.Quotation.Service.Model.Sys;
using Ongoal.Quotation.Service.Param;
using Ongoal.Quotation.Service.ViewModel;

namespace Ongoal.Quotation.WebAPI.Controllers
{
    /// <summary>
    /// 菜单相关接口
    /// </summary>
    public class MenuController : WebAPIBase
    {
        private IMenuService _service;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="service"></param>
        public MenuController(IMenuService service)
        {
            _service = service;
        }
        /// <summary>
        /// 获取菜单列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public dynamic GetMenu()
        {
            return _service.GetMenu();
        }
        /// <summary>
        /// 获取菜单树
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="MenuType"></param>
        /// <returns></returns>
        [HttpGet]
        public object GetMenuTree(string keyword,int MenuType) {
            return _service.GetMenuTree(keyword, MenuType);
        }
        /// <summary>
        /// 增加菜单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
         [HttpPost]
        public object AddMenu([FromBody]Menu model) {
            return _service.AddMenu(model);
        }

        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public object EditMenu([FromBody] Menu model) {
            return _service.EditMenu(model);
        }

        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
     [HttpPost]
        public object DeleteMenu([FromBody] List<int> Ids) {
            return _service.DeleteMenu(Ids);

        }
        /// <summary>
        /// 获取当前菜单的操作
        /// </summary>
        /// <param name="MenuID"></param>
        /// <returns></returns>
         [HttpGet]
        public object GetMenuOperate(int MenuID) {
            return _service.GetMenuOperate(MenuID);
        }
        /// <summary>
        /// 获取当前菜单未授权的操作
        /// </summary>
        /// <param name="MenuID"></param>
        /// <returns></returns>
        [HttpGet]
        public object GetNotMenuOperate(int MenuID,string keyword)
        {
            return _service.GetNotMenuOperate(MenuID, keyword);
        }

        /// <summary>
        /// 新增菜单操作数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public object AddMenuOperate([FromBody] Receivemoviews model) {
            return _service.AddMenuOperate(model.menuid, model.operateids);
        }

        /// <summary>
        /// 拖动
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="type"></param>
      [HttpPost]
        public void DraggleMenu([FromBody]ReceiveDraggle model) {
             _service.DraggleMenu(model.source,model.target,model.type);
        
        }
        /// <summary>
        /// 移除菜单操作数据
        /// </summary>
        /// <param name="tids"></param>
        /// <returns></returns>
        [HttpPost]
        public bool RemoveMenuOperate([FromBody]List<int> tids) {
            return _service.RemoveMenuOperate(tids);
        }
        /// <summary>
        /// 获取已经授权的数据项类型
        /// </summary>
        /// <param name="MenuID"></param>
        /// <returns></returns>
       [HttpGet]
        public object GetMenuDataItem(int MenuID) {
            return _service.GetMenuDataItem(MenuID);
        }
        /// <summary>
        /// 分配数据项
        /// </summary>
        /// <param name="model"></param>
        [HttpPost]
        public object AddMenuDataItem([FromBody]Receivedataitem model) {
            return _service.AddMenuDataItem(model.MenuID,model.catagoryids);
        }
        /// <summary>
        /// 移除数据项
        /// </summary>
        /// <param name="model"></param>
        [HttpPost]
        public object RemoveDataItem([FromBody] Receivedataitem model)
        {
            return _service.RemoveDataItem(model.MenuID, model.catagoryids);
        }


        /// <summary>
        /// 获取没有加入常用功能的菜单集合
        /// </summary>
        /// <returns></returns>
       [HttpGet]
        public object GetMenuNotUsual() {

            return _service.GetMenuNotUsual();
        }
        /// <summary>
        /// 获取常用功能集合
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public object GetUsualMenu() {
            return _service.GetUsualMenu();

        }
        /// <summary>
        /// 新增常用功能
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public object AddOUsualFunction([FromBody]List<int> ids) {
            return _service.AddOUsualFunction(ids);
        }

    }
}
